#ifndef MESSAGE_MGR_HTTPCLIENT_H
#define MESSAGE_MGR_HTTPCLIENT_H

#include "httplib.h"

//
// httpclient 连接 java_server, 向 java_server POST 数据, 然后 java_server 放入到 mq 中,
// curl -X POST http://192.168.100.81:8080/ys_provider/providerController/sendQueue.do  -H 'content-type:application/json' -d "{\"user\":\"root\", \"password\":\"admin\"}"
//

// 
// 反向代理, 请求源站时候, 需要用到的函数,
// 

namespace nmsp
{
    class Httpclient
    {
    public:
        Httpclient(const char *addr) : m_cli(addr) {}

    public:
        httplib::Result Get(const char *path) { return m_cli.Get(path); }

        httplib::Result Post(const char *path, const char *body, size_t content_length, const char *content_type)
        {
            return m_cli.Post(path, body, content_length, content_type);
        }

        httplib::Result Post(const char *path, const httplib::Headers &headers, const char *body, size_t content_length, const char *content_type)
        {
            return m_cli.Post(path, headers, body, content_length, content_type);
        }

        httplib::Result Post(const char *path, const std::string &body, const char *content_type)
        {
            return m_cli.Post(path, body, content_type);
        }

        httplib::Result Post(const char *path, const httplib::Headers &headers, const std::string &body, const char *content_type)
        {
            return m_cli.Post(path, headers, body, content_type);
        }

    private:
        httplib::Client m_cli;
    };
}

#endif
